var pathRequestUrl;
//var START_INDEX = 7;

Ext.onReady(function(){
    Ext.QuickTips.init();
    pathRequestUrl = '';
    
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	
	var ds = new Ext.data.GroupingStore({
		proxy: new Ext.data.HttpProxy({
			url: pathRequestUrl
		}),
		
		reader: new Ext.data.JsonReader({
			id:   'id',
			totalProperty: 'total',
			root: 'data'
		}, Ext.data.Record.create([
			{name:'id'}, 
			{name:'object_number'}, 
			{name:'object_name'}, 
			{name:'company'}, 
			{name:'address'}, 
			{name:'phone'},
			{name:'mobile'},
			{name:'email'},
			{name:'fax'},
			{name:'type'}]))/*,
		
			groupField: 'size',
			sortInfo: {field: 'name', direction: 'ASC'},
			remoteSort: false*/
		});
			
	var filters = new Ext.ux.grid.GridFilters({filters:[
			{type: 'numeric',  dataIndex: 'id'},
			{type: 'string',  dataIndex: 'object_number'},
			{type: 'string',  dataIndex: 'object_name'},
			{type: 'string',  dataIndex: 'company'},
			{type: 'string',  dataIndex: 'address'},
			{type: 'string',  dataIndex: 'phone'},
			{type: 'string',  dataIndex: 'mobile'},
			{type: 'string',  dataIndex: 'email'},
			{type: 'string',  dataIndex: 'fax'},
			{
				type: 'list',  
				dataIndex: 'type', 
				options: ['Ca Sĩ', 'Nhạc Sĩ'],
				phpMode: true
			}
	]});
			
	var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
              	dataIndex: 'object_number',
              	header: 'Mã Số'
            }, {
            	dataIndex: 'object_name',
              	header: 'Tên'
            }, {
            	dataIndex: 'type',
              	header: 'Đối Tượng'
            }, {
            	dataIndex: 'company',
              	header: 'Công Ty'
            }, {
            	dataIndex: 'address',
              	header: 'Địa Chỉ'
            }, {
            	dataIndex: 'phone',
            	header: 'Điện Thoại'
            }, {
                dataIndex: 'phone',
                header: 'Điện Thoại'
            }, {
                dataIndex: 'mobile',
                header: 'Di Động'
            }, {
                dataIndex: 'email',
                header: 'Email'
            }, {
                dataIndex: 'fax',
                header: 'Fax'
            }]);
			cm.defaultSortable = true;
			
	var grid = new Ext.grid.GridPanel({
		title: 'QL Thông Tin Ca/Nhạc Sĩ',
		id: 'grid_list_object',
		ds: ds,
		cm: cm,
		enableColLock: false,
		loadMask: true,
		view: new Ext.grid.GroupingView(),
		plugins: filters,
		height:400,
		width:700,
				
		el: 'list_object',
				
		bbar: new Ext.PagingToolbar({
        store: ds,
        pageSize: 15/*,
        plugins: filters*/
	})
	});
	grid.render();
				
//	ds.load({params:{start: 0, limit: 15}});

});
